package JAVA;

import javax.swing.plaf.IconUIResource;
import java.util.Arrays;
import java.util.Scanner;

public class work3111 {
    //对一维数组进行增删改查操作：int[] numbers = new int[10]
    //要求实现如下需求：
    public static void main(String[] args) {
        int[]num=new int[10];
        System.out.println("请依次输入10个数字 ");
        for (int i=0;i<10;i++){
            Scanner input=new Scanner(System.in);
            num[i]=input.nextInt();
        }
        System.out.println("数组如下");
        for (int i=0;i<10;i++){
            System.out.print("num["+i+"]="+num[i]+" ");
        }
        System.out.println("请选择功能");
        System.out.println("1、删除");
        System.out.println("2、修改");
        System.out.println("3、查找");
        System.out.println("4、增加");
        Scanner sc=new Scanner(System.in);
        int b= sc.nextInt();
        switch (b){
            case 1:
                System.out.println("请选择删除数字的下标");
                Scanner s0=new Scanner(System.in);
                int c= s0.nextInt();
                    for (int i=0;i<10;i++){
                        if (i==c){
                            continue;
                    }
                    System.out.println(num[i]+"");
                    break;
                }
            case 2:
                System.out.println("请选择修改数字的下标");
                Scanner s1=new Scanner(System.in);
                int d=s1.nextInt();
                System.out.println("输入新数字");
                Scanner s11=new Scanner(System.in);
                int d1= s11.nextInt();
                Arrays.fill(num,d,d+1,d1);
                for (int i=0;i<10;i++){
                    System.out.println("num["+i+"]="+num[i]+"");
                }
            case 3:
                System.out.println("请输入你要查找的数字");
                Scanner s2=new Scanner(System.in);
                int s= s2.nextInt();
                for (int i=0;i<10;i++){
                    if (s==num[i]){
                        int j=i;
                        System.out.println("下标是"+j);
                    }
                    if (i==9){
                        System.out.println("查无此数");
                    }
                }
            }
    }
}
